package com.red.controller;

import com.red.pojo.Result;
import com.red.pojo.model.LoginUser;
import com.red.service.IFightService;
import com.red.util.JWTUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class FightController {

    @Autowired
    private IFightService fightService;

    @PostMapping("/fight/{houseId}")
    public Result fight(@PathVariable int houseId, HttpServletRequest request) {
        LoginUser loginUser = JWTUtil.getLoginUser(request);

        return fightService.fight(loginUser.getUserID(), houseId);
    }
}
